package net.fdukedom.epicurus.tools.config;

import java.util.PropertyResourceBundle;
import java.util.ResourceBundle;

/**
 * Application configuration.
 *
 * @author Dmitry Y. Kochelaev
 */
public class Configuration {

    /**
     * Class instance.
     */
    private static Configuration instance = new Configuration();

    /**
     * Resources.
     */
    private ResourceBundle bundle;

    /**
     * Utility class.
     */
    private Configuration() {
        bundle = PropertyResourceBundle.getBundle("bundles.Configuration");
    }

    /**
     * Returns instance of class.
     *
     * @return instance of class
     */
    public static Configuration getInstance() {
        return instance;
    }

    /**
     * Returns string value of property for the key.
     *
     * @param key key to look up for.
     *
     * @return string value of property for the key
     */
    public String getStringValue(Key key) {
        return bundle.getString(key.getValue());
    }

    /**
     * Returns string value of property for the key.
     *
     * @param key key to look up for.
     *
     * @return string value of property for the key
     */
    public String getStringValue(String key) {
        return bundle.getString(key);
    }

    /**
     * Returns int value of property for the key.
     *
     * @param key key to look up for.
     *
     * @return int value of property for the key
     */
    public int getIntValue(Key key) {
        return Integer.parseInt(bundle.getString(key.getValue()));
    }

    /**
     * Returns int value of property for the key.
     *
     * @param key key to look up for.
     *
     * @return int value of property for the key
     */
    public int getIntValue(String key) {
        return Integer.parseInt(bundle.getString(key));
    }

    /**
     * Returns boolean value of property for the key.
     *
     * @param key key to look up for.
     *
     * @return boolean value of property for the key
     */
    public boolean getBooleanValue(Key key) {
        return Boolean.parseBoolean(bundle.getString(key.getValue()));
    }

    /**
     * Returns boolean value of property for the key.
     *
     * @param key key to look up for.
     *
     * @return boolean value of property for the key
     */
    public boolean getBooleanValue(String key) {
        return Boolean.parseBoolean(bundle.getString(key));
    }
}
